﻿using System;
using IInject.Registration;

namespace IInject.Resolution
{
	public class TypeDependency : Dependency<Type, PropertyDependency>
	{
		private readonly RegistryContext _context;

		public TypeDependency(RegistryContext context) : base(DependencyType.Type)
		{
			_context = context;
			Dependent = context.ToType;

			var properties = context.Properties;

			if (properties.Count > 0)
			{
				for (int i = 0; i < properties.Count; i++)
				{
					Dependencies.Add(new PropertyDependency(properties[i]));
				}
			}
		}

		public Scope Scope
		{
			get
			{
				return _context.Scope;
			}
			set
			{
				_context.Scope = value;
			}
		}

		public object Instance
		{
			get
			{
				return _context.Instance;
			}
			set
			{
				_context.Instance = value;
			}
		}

		public RegistryContext Context
		{
			get
			{
				return _context;
			}
		}

		public ConstructorDependency Constructor { get; set; }
	}
}
